//
//  HDNewsDetailViewController.swift
//  Excited
//
//  Created by X140Yu on 6/23/16.
//  Copyright © 2016 X140Yu. All rights reserved.
//

import UIKit
import RxCocoa
import RxSwift
import WebKit
import SnapKit

class HDNewsDetailViewController: UIViewController {
    let webView = WKWebView()

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        
        webView.scrollView.contentSize = UIScreen.mainScreen().bounds.size
        view.addSubview(webView)
        webView.snp_makeConstraints { (make) in
            make.edges.equalTo(0)
        }
    }
    
    func setContentWith(nid: String) {
        HDNetwork.fetchNewsItemWith(nid, completion: { [unowned self] (news) in
            let htmlString = "<html><head><meta charset=\"utf-8\"><link rel=\"stylesheet\" href=\"style.css\"><meta name=\"viewport\" content=\"initial-scale=1.0\" /></head><body>\(news.content!)</body></html>"
            self.webView.loadHTMLString(htmlString, baseURL: nil)
            }) { (message) in
        }
    }

}
